using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.obj
{
[System.Serializable]
public  class UIOperation : Singleton
 {

    public cfg.obj.EHintType hintType ;
     public string hintPath  = "";
     public float radius ;
     public System.Collections.Generic.List<cfg.obj.UIOperationItem> operations  = new System.Collections.Generic.List<cfg.obj.UIOperationItem>();
     


    public const int TYPE_ID = 1547063602;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(6);
        os.WriteSize(Tag.BOOL | (1 << Tag.TAG_SHIFT));  os.WriteBool(enable);  
         os.WriteSize(Tag.INT | (2 << Tag.TAG_SHIFT));  os.WriteInt(cfgId);  
         os.WriteSize(Tag.INT | (101 << Tag.TAG_SHIFT));  os.WriteInt((int)hintType);  
         os.WriteSize(Tag.STRING | (102 << Tag.TAG_SHIFT));  os.WriteString(hintPath);  
         os.WriteSize(Tag.FLOAT | (103 << Tag.TAG_SHIFT));  os.WriteFloat(radius);  
         os.WriteSize(Tag.LIST | (104 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_obj_UIOperationItem(operations,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.BOOL | (1 << Tag.TAG_SHIFT)):   enable = os.ReadBool(); break;  
             case (Tag.INT | (2 << Tag.TAG_SHIFT)):   cfgId = os.ReadInt(); break;  
             case (Tag.INT | (101 << Tag.TAG_SHIFT)):   hintType = (cfg.obj.EHintType)(os.ReadInt()); break;  
             case (Tag.STRING | (102 << Tag.TAG_SHIFT)):   hintPath = os.ReadString(); break;  
             case (Tag.FLOAT | (103 << Tag.TAG_SHIFT)):   radius = os.ReadFloat(); break;  
             case (Tag.LIST | (104 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); operations = cfg.Extensions.unmarshal_compatible_list_cfg_obj_UIOperationItem(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "UIOperation");
        ele.WriteStartElement("enable"); ele.WriteAttributeString("id", "1"); ele.WriteBool(enable); ele.WriteEndElement();
         ele.WriteStartElement("cfgId"); ele.WriteAttributeString("id", "2"); ele.WriteInt(cfgId); ele.WriteEndElement();
         ele.WriteStartElement("hintType"); ele.WriteAttributeString("id", "101"); ele.WriteEnum(hintType); ele.WriteEndElement();
         ele.WriteStartElement("hintPath"); ele.WriteAttributeString("id", "102"); ele.WriteString2(hintPath); ele.WriteEndElement();
         ele.WriteStartElement("radius"); ele.WriteAttributeString("id", "103"); ele.WriteFloat(radius); ele.WriteEndElement();
         ele.WriteStartElement("operations"); ele.WriteAttributeString("id", "104"); cfg.Extensions.xml_marshal_list_cfg_obj_UIOperationItem(operations,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  enable = ele.ReadBool(); break; 
                 case 2:  cfgId = ele.ReadInt(); break; 
                 case 101:  hintType = ele.ReadEnum<cfg.obj.EHintType>(); break; 
                 case 102:  hintPath = ele.ReadString2(); break; 
                 case 103:  radius = ele.ReadFloat(); break; 
                 case 104:  operations = cfg.Extensions.xml_unmarshal_list_cfg_obj_UIOperationItem(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "enable":  enable = ele.ReadBool(); break; 
                 case "cfg_id":  cfgId = ele.ReadInt(); break; 
                 case "hint_type":  hintType = ele.ReadEnum<cfg.obj.EHintType>(); break; 
                 case "hint_path":  hintPath = ele.ReadString2(); break; 
                 case "radius":  radius = ele.ReadFloat(); break; 
                 case "operations":  operations = cfg.Extensions.xml_unmarshal_list_cfg_obj_UIOperationItem(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
